<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增劳务用工合同')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<style>
    .jltable{
        margin: auto;
    }
    .jltable th,td{
        min-height: 40px;
        min-width: 50px;
        border: 1px solid #eee;
        padding: 10px;
    }
</style>
<body class="white-bg">

    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-yght-add">
            <h4 class="form-header h4">合同信息</h4>
            <table class="jltable">
                <tbody>
                    <tr>
                        <td> <label class="control-label">合同名称</label></td>
                        <td><input name="htmc" class="form-control" type="text"></td>
                        <td><label class="control-label">用工单位</label></td>
                        <td><input name="ygdw" class="form-control" type="text"></td>
                    </tr>
                    <tr>
                        <td> <label class="control-label">签署人</label></td>
                        <td>
                            <input type="hidden" name="qsr" class="form-control">
                            <select  class="form-control" id="qsr_select"></select>
                        </td>
                        <td> <label class="control-label">员工类型</label></td>
                        <td>
                            <select name="yglx" class="form-control noselect2 selectpicker" th:with="type=${@dict.getType('lwpq_ygfl')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td> <label class="control-label is-required">签署公司</label></td>
                        <td> <input name="qsgs" class="form-control" type="text" required></td>
                        <td> <label class="control-label">身份证号</label></td>
                        <td><input name="sfzh" class="form-control" type="text"></td>
                    </tr>
                    <tr>
                        <td><label class="control-label">营业执照号</label></td>
                        <td><input name="yyzzh" class="form-control" type="text"></td>
                        <td><label class="control-label">状态</label></td>
                        <td>
                            <select name="zt" class="form-control" th:with="type=${@dict.getType('yghtzt')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="control-label">合同类型</label></td>
                        <td>
                            <select name="htlx" class="form-control" th:with="type=${@dict.getType('pqhtlx')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </td>
                        <td><label class=" control-label">签约状态</label></td>
                        <td> <input name="qyzt" class="form-control" type="text"></td>
                    </tr>
                    <tr>
                       <td><label class="control-label">合同期限</label></td>
                        <td><input name="htqx" class="form-control" type="text"></td>
                        <td> <label class=" control-label">试用期</label></td>
                        <td> <input name="syq" class="form-control" type="text"></td>
                    </tr>
                    <tr>
                        <td><label class="control-label">入职日期</label></td>
                        <td>
                            <div class="input-group date">
                                <input name="rzrq" class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </td>
                        <td><label class="control-label">开始日期</label></td>
                        <td>
                            <div class="input-group date">
                                <input name="ksrq" class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="control-label">转正日期</label></td>
                        <td>
                            <div class="input-group date">
                                <input name="zzrq" class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </td>
                        <td><label class=" control-label">截至日期</label></td>
                        <td>
                            <div class="input-group date">
                                <input name="jzrq" class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="control-label">提前终止</label></td>
                        <td>
                            <div class="input-group date">
                                <input name="tqzz" class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </td>
                        <td> <label class="control-label">签订时间</label></td>
                        <td>
                            <div class="input-group date">
                                <input name="qdsj" class="form-control" placeholder="yyyy-MM-dd" type="text">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="control-label">合同内容</label></td>
                        <td colspan="3"> <textarea name="htnr" class="form-control"></textarea></td>
                    </tr>
                    <tr>
                        <td><label class="control-label">相关文件</label></td>
                        <td colspan="3">
                            <div>
                                <input type="hidden" name="xgwj">
                                <div class="file-loading">
                                    <input class="form-control file-upload" id="xgwj" name="file" type="file">
                                </div>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "lwpq/yght"
        $("#form-yght-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-yght-add').serialize());
            }
        }

        $("input[name='rzrq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='ksrq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='zzrq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='jzrq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='tqzz']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='qdsj']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function (){
            function formatRepo(repo){
                return  repo.name || repo.text;
            }
            function formatRepoSelection(repo){
                return  repo.name || repo.text;
            }

            $('#qsr_select').select2({
                ajax:{
                    url: ctx + 'lwpq/jl/list',
                    type:'post',
                    dataType:'json',
                    data:function (params) {
                        let query = {
                            name:params.term,
                            zt:'',
                        }
                        return query;
                    },
                    processResults : function (data){
                        let res = new Array();
                        data.rows.forEach(value => {
                            res.push({
                                id : value.id,
                                text : value.name,
                                ob:value
                            })
                        })
                        return {
                            results : res
                        };
                    },
                    minimumInputLength : 1,
                    maximumInputLength : 20,
                    templateResult : formatRepo,
                    templateSelection : formatRepoSelection,
                }
            })
            $('#qsr_select').on('select2:select', function (e) {
                // 处理业务
                let ob =  e.params.data.ob;
                $("input[name='qsr']").val(ob.name);
                $("input[name='sfzh']").val(ob.sfzh);
            });
        })

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace:true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>